<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::get('/test/{id}', function ($id) {   //必选参数传参
    echo 'userId: '.$id;
});
Route::get('/test/{id?}', function ($id = null) {   //可选参数传参
    echo 'userId: '.$id;
});
Route::post('/hello',function (){
    echo "请求方法为post";              //无提交报错
});
Route::any('/any',function (){
    echo "请求方法为any";
});

Route::any('/test5','TestController@test5');  //依赖注入，利用request对象获取请求
Route::any('/test5/view',function (){
    return view('home.test.request');
});
Route::any('/test5/add','TestController@mAdd');  //依赖注入，利用request对象获取请求并添加到数据库

Route::any('/name',function (){
    echo "id:11";
})->name('id');         //路由别名

Route::match(['get','post'],'/match',function (){  //匹配数组内的请求方法
    echo "请求方法为match ".'编号：'.$_GET['id'];  //传统get方法
});


//路由群组
Route::group(['prefix'=>'admin'],function (){
    Route::get('/group1',function (){
        echo 'admin/group1';
    });
});


Route::any('/home/test/test1','TestController@test1'); //控制器路由配置
Route::any('/home/test/test2','TestController@test2'); //控制器路由配置

Route::any('/home/admin/index','Admin\IndexController@index'); //分目录管理
Route::any('/home/Home/index','Home\IndexController@index');

//数据库操作
Route::any('/home/DB/add','TestController@add');
Route::any('/home/DB/del','TestController@del');
Route::any('/home/DB/update','TestController@update');
Route::any('/home/DB/sel','TestController@sel');

//视图操作

Route::any('/home/view/test1','TestController@test3');
Route::any('/home/view/test2','TestController@test4');

//视图模版继承
Route::any('/home/view/test3','TestController@test6');

//csrf
Route::any('/home/view/test4','TestController@test7');
Route::any('/home/view/test5',function (){
    echo "提交成功";
});

//模型操作数据库

Route::any('/home/model/add','TestController@mAdd');
Route::any('/home/model/del','TestController@mDel');
Route::any('/home/model/update','TestController@mUpdate');
Route::any('/home/model/sel','TestController@mSel');

//自动验证
Route::any('/home/val','TestController@val');

//文件上传
Route::any('/home/upload','TestController@fileUpload');

//分叶操作
Route::any('/home/page','TestController@page');

//ajax响应
Route::any('/home/view/ajax',function (){
    return view('home.test.ajax');
});
Route::any('/home/ajax','TestController@ajax');

//会话控制
Route::any('/home/sess','TestController@sess');


//缓存操作
Route::any('/home/cache','TestController@cache');

//联表查询
Route::any('/home/TATSel','TestController@TATSel');

//关联模型（一对一）
Route::any('/home/oneToOne','TestController@oneToOne');
//关联模型（一对多）
Route::any('/home/oneToMany','TestController@oneToMany');
//关联模型（多对多）
Route::any('/home/manyToMany','TestController@manyToMany');









